<template>
	<view class="">
		<view>
			<input type="text" class="uni-input border-0" placeholder="输入邮箱" v-model="emial" />

			<input type="safe-password" class="uni-input border-0" placeholder="输入密码" v-model="password" />
		</view>

		<button class="text-light bg-main-disabled mt-3" :class="istrue ? 'bg-main' : ''" @click="submit">提交</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			emial: '',
			password: ''
		};
	},
	computed: {
		istrue() {
			if (this.emial && this.password) {
				return true;
			} else {
				return false;
			}
		}
	},
	methods: {
		chek(email) {
			let szReg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,5}$/;
			let bChk = szReg.test(email);
			return bChk;
		},
		submit() {
			if(this.emial===''||this.password==='')
			{
				uni.showToast({
					title: '请输入完整',
					icon: 'none'
				});
				return
			}
			let k = this.chek(this.emial);
			if (!k) {
				uni.showToast({
					title: '请输入正确的邮箱',
					icon: 'none'
				});
				return;
			}
			console.log('正确');
		}
	}
};
</script>

<style></style>
